<template>
    <view class="content">
        <image src="../../static/image/bg.jpg" class="bg-02"></image>
        <u-navbar :background="background" title="首页" title-size="32" title-color="#000" :border-bottom="false" :is-back="false" :immersive="true"></u-navbar>
        
        <view class="wrapper" :style="{paddingTop: statusBar + 60 + 'px'}">
            <view class="name">谊安医药</view>
            <view class="sub-name">信息管理系统</view>
            <view class="u-flex">
                <view class="version">V1.0</view>
                <view></view>
            </view>
            
            <view class="box">
                <view class="item" @click="toPage(`/pages/nav/enter`)">
                    <image src="../../static/image/img_01.png" class="img-01"></image>
                    <view class="u-flex-1">
                        <view>入库管理子系统</view>
                        <view class="see">查看入库单信息</view>
                    </view>
                    <view class="btn">查看</view>
                </view>
                <view class="item" @click="toPage(`/pages/nav/sort`)">
                    <image src="../../static/image/img_02.png" class="img-01"></image>
                    <view class="u-flex-1">
                        <view>分拣规划子系统</view>
                        <view class="see">查看分拣规划信息</view>
                    </view>
                    <view class="btn">查看</view>
                </view>
                <view class="item" @click="toPage(`/pages/nav/warehouse`)">
                    <image src="../../static/image/img_03.png" class="img-01"></image>
                    <view class="u-flex-1">
                        <view>仓库管理子系统</view>
                        <view class="see">查看仓库管理信息</view>
                    </view>
                    <view class="btn">查看</view>
                </view>
                <view class="item" @click="toPage(`/pages/nav/transport`)">
                    <image src="../../static/image/img_04.png" class="img-01"></image>
                    <view class="u-flex-1">
                        <view>运输配送子系统</view>
                        <view class="see">查看运输配送信息</view>
                    </view>
                    <view class="btn">查看</view>
                </view>
                <view class="item" @click="toPage(`/pages/nav/refund`)">
                    <image src="../../static/image/img_05.png" class="img-01"></image>
                    <view class="u-flex-1">
                        <view>退货管理子系统</view>
                        <view class="see">查看退货管理信息</view>
                    </view>
                    <view class="btn">查看</view>
                </view>
            </view>
            
            <view class="footer" v-if="isLogin" @click="logOut">退出登录</view>
            <view class="footer" v-else @click="$gTo(`/pages/login/login`)">登录</view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                background: {
                    backgroundColor: 'rgba(255,255,255,0)',
                },
                statusBar: 0,
                isLogin: 0,
            };
        },
        onLoad() {
            let _this = this;
            //状态栏高度
            uni.getSystemInfo({
                success: function(res) {
                    _this.statusBar = res.statusBarHeight;
                }
            });
            
            uni.$on('LOGIN', data => {
                this.isLogin = 1
            })
        },
		onShow() {
			if (this.$getSync('userToken')) {
				this.isLogin = 1
			}
		},
        methods: {
            // 退出登录
            logOut() {
                this.$confirm('确定退出登录吗？', () => {
                    this.isLogin = 0
                    uni.removeStorageSync('userInfo')
                    uni.removeStorageSync('userToken')
                    uni.removeStorageSync('userId')
                })
            },
            
            toPage(url) {
                if (!this.$getSync('userToken')) {
                    this.$gTo(`/pages/login/login`)
                    return
                } else {
                    this.$gTo(url)
                }
            },
            
            // 滚动监听
            onPageScroll: function(e) {
                //nvue暂不支持滚动监听，可用bindingx代替
                // console.log("滚动距离为：" + e.scrollTop);
                let a = e.scrollTop * 0.05;
                if (a > 1) {
                    a = 1;
                }
                if (e.scrollTop == 0) {
                    this.background.backgroundColor = 'rgba(255,255,255,0)';
                } else {
                    this.background.backgroundColor = 'rgba(255,255,255,' + a + ')';
                }
            },
        }
    };
</script>

<style lang="scss">
    
    page{
        background-color: #f8f6f7 !important;
    }
    .bg-02{
        width: 750rpx;
        height: 620rpx;
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;
    }
    .wrapper{
        padding: 20rpx;
    }
    .name{
        font-size: 44rpx;
        font-weight: bold;
        background-image:linear-gradient(left, #ff3100, #ff6500);
        -webkit-background-clip: text; 
        -webkit-text-fill-color: transparent;
        padding-left: 10rpx;
    }
    .sub-name{
        font-size: 44rpx;
        font-weight: bold;
        color: #000;
        padding-bottom: 15rpx;
        padding-left: 10rpx;
    }
    .version{
        font-size: 26rpx;
        font-weight: bold;
        color: #fff;
        line-height: 1;
        padding: 6rpx 10rpx;
        background-color: #ff4800;
        border-radius: 10rpx;
        margin-left: 10rpx;
    }
    
    
    .box{
        padding: 80rpx 0 120rpx;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: #fff;
        border-radius: 20rpx;
        padding: 35rpx 40rpx;
        margin-bottom: 20rpx;
        font-size: 36rpx;
        font-weight: bold;
    }
    .img-01{
        width: 95rpx;
        height: 95rpx;
        margin-right: 50rpx;
    }
    .see{
        font-size: 24rpx;
        color: #b6b6b6;
        font-weight: normal;
        padding-top: 10rpx;
    }
    .btn{
        font-size: 26rpx;
        color: #59687e;
        font-weight: normal;
        padding: 15rpx 35rpx;
        background-color: #f6f7fa;
        border-radius: 50rpx;
    }
    .footer{
        width: 100%;
        height: 95rpx;
        background-color: #fff;
        font-size: 34rpx;
        color: #ff4800;
        font-weight: bold;
        line-height: 95rpx;
        text-align: center;
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 9;
    }

</style>
